import request from '@/utils/request';

export async function allAddressesServer(data) {
  return request({
    url: '/mb/addresses',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
    data: data,
    method: 'GET',
  });
}
export async function adressDeleteServer(data) {
  return request({
    url: '/mb/addresses/' + data.addressId,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
    method: 'DELETE',
  });
}
export async function adressNewAddServer(data) {
  return request({
    url: '/mb/addresses',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
    data: data,
    method: 'POST',
  });
}
export async function adressDetailServer(data) {
  return request({
    url: `/mb/addresses/${data}`,
    method: 'GET',
  });
}
export async function adressNewEditServer(data, id) {
  return request({
    url: `/mb/addresses/${id}`,
    method: 'PUT',
    data: data,
  });
}

export async function getAppConfigurationServer() {
  return request({
    url: '/merchant/merchant/colorConfig/getAppConfiguration',
    method: 'GET',
  });
}

export async function hotCouponListServer() {
  return request({
    url: '/wallet/app/fineCoupon/selectHotCouponList',
    method: 'GET',
  });
}

export async function directionalCouponListServer() {
  return request({
    url: '/wallet/app/fineCoupon/selectMyPromoTask',
    method: 'GET',
  });
}

export async function receiveDirectionalCouponServer(data) {
  return request({
    url: '/wallet/app/fineCoupon/receiveMyPromoTask',
    method: 'POST',
    data: data,
  });
}

export async function couponListServer(data) {
  return request({
    url: '/wallet/app/fineCoupon/selectCenterPage',
    method: 'POST',
    data: data,
  });
}

export async function createCouponServer(data) {
  return request({
    url: '/wallet/app/fineCoupon/receiveByCenter',
    method: 'POST',
    data: data,
  });
}

export async function myCouponServer(data) {
  return request({
    url: '/wallet/app/fineCoupon/selectMyCouponList',
    method: 'POST',
    data: data,
  });
}

export async function orderCouponListServer(data) {
  return request({
    url: '/wallet/app/fineCoupon/selectFineCouponListV2',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
    data: data,
  });
}

export async function couponProductsInfoServer(data) {
  return request({
    url: '/wallet/app/fineCoupon/selectProductPageList',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
    data: data,
  });
}

// 小程序劵适用商品购物车金额结算
export async function getCouponProductInCartPriceServer(data) {
  const { configId, sourceType } = data;
  return request({
    url: `/wallet/app/fineCoupon/countProductAmount/${configId}/${sourceType}`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

export async function couponShopListServer(data) {
  return request({
    url: '/wallet/app/fineCoupon/selectOrgPageList',
    method: 'POST',
    data: data,
  });
}

export async function selectProductCouponListServer(data) {
  return request({
    url: '/wallet/app/fineCoupon/selectProductCouponList',
    method: 'POST',
    data: data,
  });
}

// 获取服务器当前时间
export async function getServerCurrentTime() {
  return request({
    url: `/wallet/app/fineCoupon/selectCurrentTime`,
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}

// 获取我的礼品卡列表
export async function myGiftCardListServer(data) {
  return request({
    url: `/wallet/app/fineGiftCard/getMyGiftCardPageList`,
    method: 'POST',
    data,
  });
}

// 获取我的礼品卡详情
export async function myGiftCardServer(cardId) {
  return request({
    url: `/wallet/app/fineGiftCard/getMyGiftCardInfo/${cardId}`,
    method: 'GET',
  });
}

// 获取礼品卡列表
export async function giftCardListServer(data) {
  return request({
    url: `/wallet/app/fineGiftCard/getGiftCardPageList`,
    method: 'POST',
    data,
  });
}

// 获取礼品卡总余额
export async function myGiftCardAmountServer(data) {
  return request({
    url: `/wallet/app/fineGiftCard/getMyGiftCardAmount`,
    method: 'GET',
    data,
  });
}

// 获取礼品卡消费记录
export async function myGiftCardTransactionListServer(data) {
  return request({
    url: `/wallet/app/fineGiftCard/getTransactionRecordsByUserId`,
    method: 'POST',
    data,
  });
}

// 礼品卡绑定
export async function bindGiftCardServer(data) {
  return request({
    url: `/wallet/app/fineGiftCard/fineCardTaskBinding`,
    method: 'POST',
    data,
  });
}

// 获取礼品卡详情
export async function giftCardInfoServer(cardId) {
  return request({
    url: `/wallet/app/fineGiftCard/getGiftCardInfo/${cardId}`,
    method: 'GET',
  });
}

// 获取礼品卡储值金额列表
export async function rechargeAmountServer(cardId) {
  return request({
    url: `/wallet/app/fineGiftCard/getRechargeAmount/${cardId}`,
    method: 'GET',
  });
}

// 获取礼品卡店铺列表
export async function giftCardStoreListServer(data) {
  return request({
    url: `/wallet/app/fineGiftCard/getGiftCardStoreInfo`,
    method: 'POST',
    data,
  });
}

// 礼品卡储值
export async function payGiftCardServer(data) {
  return request({
    url: `/wallet/app/fineGiftCard/toGiftCardRecharge`,
    method: 'POST',
    data,
  });
}

// 获取礼品卡储值记录
export async function orderListServer(data) {
  return request({
    url: `/wallet/app/fineGiftCard/getGiftCardRechargePage`,
    method: 'POST',
    data,
  });
}

// 活动分页列表
export async function activityListServer(data) {
  return request({
    url: `/product/product/fineActivity/listHomePageList`,
    method: 'POST',
    data,
  });
}

// 活动适用商品金额结算
export async function activityProductAmtServer(activityId) {
  return request({
    url: `/product/product/fineActivity/countProductAmt/${activityId}`,
    method: 'GET',
  });
}

// 活动中的商品分页列表
export async function activityProductListServer(data) {
  return request({
    url: `/product/product/fineActivity/listProductPageList`,
    method: 'POST',
    data,
  });
}

// 行政编码转行政区
export async function getDistrictServer(data) {
  return request({
    url: `/mb/addresses/districtName`,
    method: 'GET',
    data,
  });
}

export async function getInvoiceConfigServer({ orgId }) {
  return request({
    url: `/einvoice/einvoice/config/getConfigByOrg/${orgId}`,
    method: 'GET',
  });
}

// 获取满减活动的阶梯信息
export async function activityReducesServer(activityId) {
  return request({
    url: `/product/product/fineActivity/getFullReduceInfo/${activityId}`,
    method: 'GET',
  });
}

// 自定义页面获取活动分页列表
export async function moduleActivityListServer(data) {
  return request({
    url: `/product/product/fineActivity/pageList`,
    method: 'POST',
    data,
  });
}

// 活动中的商品列表（新）SPU
export async function productListServer(data) {
  return request({
    url: `/product/product/fineActivity/getProductPageList`,
    method: 'POST',
    data,
  });
}
